//编辑器
var shopxx = {
    base: "",
    locale: "zh_CN"
};

var setting = {
    priceScale: "2",
    priceRoundType: "roundHalfUp",
    currencySign: "￥",
    currencyUnit: "元",
    uploadImageExtension: "jpg,jpeg,bmp,gif,png",
    uploadFlashExtension: "swf,flv",
    uploadMediaExtension: "swf,flv,mp3,mp4,wav,avi,rm,rmvb",
    uploadFileExtension: "zip,rar,7z,doc,docx,xls,xlsx,ppt,pptx"
};

//获取Cookie
function getCookie(name) {
    if (name != null) {
        var value = new RegExp("(?:^|; )" + encodeURIComponent(String(name)) + "=([^;]*)").exec(document.cookie);
        return value ? decodeURIComponent(value[1]) : null;
    }
}

// 移除Cookie
function removeCookie(name, options) {
    addCookie(name, null, options);
}

KindEditor.ready(function (K) {
    editor = K.create("#editor", {
        height: "350px",
        items: [
            "source", "|", "undo", "redo", "|", "preview", "print", "template", "cut", "copy", "paste",
            "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright",
            "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript",
            "superscript", "clearhtml", "quickformat", "selectall", "|", "fullscreen", "/",
            "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold",
            "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image",
            "flash", "media", "insertfile", "table", "hr", "emoticons", "baidumap", "pagebreak",
            "anchor", "link", "unlink"
        ],
        langType: shopxx.locale,
        syncType: "form",
        filterMode: false,
        pagebreakHtml: '<hr class="pageBreak" \/>',
        allowFileManager: true,
        filePostName: "file",
        fileManagerJson: shopxx.base + "/product/browser",
        uploadJson: shopxx.base + "/product/upload",
        uploadImageExtension: setting.uploadImageExtension,
        uploadFlashExtension: setting.uploadFlashExtension,
        uploadMediaExtension: setting.uploadMediaExtension,
        uploadFileExtension: setting.uploadFileExtension,
        extraFileUploadParams: {
            token: getCookie("token")
        },
        afterChange: function () {
            this.sync();
        }
    });
});